//package com.asset.salesforce.service;
//
//import java.util.HashSet;
//import java.util.Set;
//
//import org.apache.shiro.crypto.hash.Sha256Hash;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//
//import com.asset.salesforce.domain.Login;
//import com.asset.salesforce.domain.Role;
//import com.asset.salesforce.domain.User;
//
//@Service
//@Transactional(readOnly=false)
//public class BootstrapDataPopulator {
//	@Autowired
//  private UserShiroService userShiroService;
//	
//	@Autowired
//	  private RoleShiroService roleShiroService;
//  // Session factory is only injected to ensure it is initialized before this runs
//  
//  
//
//  public void afterPropertiesSet()  {
//      //because we're using an in-memory hsqldb for the sample app, a new one will be created each time the
//      //app starts, so insert the sample admin user at startup:
////      JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
//      
//System.out.println(">>>>>>>>>>@@>>>>>>>> shiro roles " + roleShiroService.countRole());
//      //if(roleShiroService.findRole("admin") == null || roleShiroService.findRole("owner") == null || roleShiroService.findRole("leadAdd") == null)
//
//      //{
//    	 
//    	  Role role1 = new Role("admin");
//    	
//    	
//    	  role1.setDescription("The administrator role only given to site admins");
//    	
//    	  Set<String> permissions = new HashSet<String>();
//
//    	  permissions.add("admin:*");
//    	  role1.setPermissions(permissions);
//    	 
//    	   User user1 = new User();
//    	   user1.setEmail("sample@shiro.apache.org");
//    	   user1.setPassword(new Sha256Hash("admin123").toHex());
//    	   user1.setUsername("admin@admin.admin");
//
//    	   Set<Role> roles = new HashSet<Role>();
//    	   roles.add(role1);
//    	   
//
//    	   user1.setRoles(roles);
//    	   Login login = new Login();
//    	   
//    	   Role role2 = new Role("owner");
//    	   Role role3 = new Role("leadgenerator");
//    	   Role role4 = new Role("salesmanager");
//    	   Role role5 = new Role("salesman");
//    	   Role role6 = new Role("bussinessdeveloper");
//    	   //rules for lead
//    	   Role role7 = new Role("leadAdd");
//    	   Role role8 = new Role("leadEdit");
//    	   Role role9 = new Role("leadDelete");
//    	   Role role10 = new Role("leadView");
//    	   Role role11 = new Role("leadConvert");
//    	   Role role12 = new Role("leadImport");
//    	   Role role13 = new Role("leadFellow");
//    	 //rules for call and appointment
//    	   Role role14 = new Role("callAdd");
//    	   Role role15 = new Role("callEdit");
//    	   Role role16 = new Role("callView");
//    	   Role role17 = new Role("appointmentAdd");
//    	   Role role18 = new Role("appointmentEdit");
//    	   Role role19 = new Role("appointmentView");
//    	   ///RULES for account
//    	   Role role20 = new Role("accountAdd");
//    	   Role role21 = new Role("accountEdit");
//    	   Role role22 = new Role("accountDelete");
//    	   Role role23 = new Role("accountView");
//    	   Role role24 = new Role("accountConvert");
//    	   Role role25 = new Role("accountFellow");
//    	   //rules for contact
//    	   Role role26 = new Role("contactAdd");
//    	   Role role27 = new Role("contactEdit");
//    	   Role role28 = new Role("contactDelete");
//    	   Role role29 = new Role("contactView");
//    	   Role role30 = new Role("contactFellow");
//    	   role2.setDescription("The owner role only given to site owner");
//    	   role3.setDescription("The lead generator role only given to site lead generator");
//    	   role4.setDescription("The sales manager role only given to site sales manager");
//    	   role5.setDescription("The sales man role only given to site sales man");
//    	   role6.setDescription("The bussiness developer role only given to site bussiness developer");
//    	   //set rule descriptions for lead
//    	   role7.setDescription("Add New Lead to the site");
//    	   role8.setDescription("Edit An Exiting Lead in the site");
//    	   role9.setDescription("Delete A Lead from the site");
//    	   role10.setDescription("View an Exiting Lead in the site");
//    	   role11.setDescription("Convert an Exiting Lead in the site");
//    	   role12.setDescription("Import new Leads to the site");
//    	   role13.setDescription("Follow an Exiting Lead in the site");
//    	   //set rules for appointment and call
//    	   role14.setDescription("Add New Appointment to the site");
//    	   role15.setDescription("Edit an Exiting Appointment in the site");
//    	   role16.setDescription("View an Exiting Appointment in the site");
//    	   role17.setDescription("Add New Call to the site");
//    	   role18.setDescription("Edit an Exiting Call in the site");
//    	   role19.setDescription("View an Exiting Call in the site");
//    	   //set rules description for account
//    	   role20.setDescription("Add New Account to the site");
//    	   role21.setDescription("Edit An Exiting Account in the site");
//    	   role22.setDescription("Delete A Account from the site");
//    	   role23.setDescription("View an Exiting Account in the site");
//    	   role24.setDescription("Convert an Exiting Account in the site");
//    	   role25.setDescription("Follow an Exiting Account in the site");
//    	   //set rules description for contact
//    	   role26.setDescription("Add New Contact to the site");
//    	   role27.setDescription("Edit An Exiting Contact in the site");
//    	   role28.setDescription("Delete A Contact from the site");
//    	   role29.setDescription("View an Exiting Contact in the site");
//    	   role30.setDescription("Follow an Exiting Contact in the site");
//    	   
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("owner:*");
//    	   role2.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadgenerator:*");
//    	   role3.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("salesmanager:*");
//    	   role4.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("salesman:*");
//    	   role5.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("bussinessdeveloper:*");
//    	   role6.setPermissions(permissions);
//    	   //set permissions for rule lead
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadAdd:*");
//    	   role7.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadEdit:*");
//    	   role8.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadDelete:*");
//    	   role9.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadView:*");
//    	   role10.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadConvert:*");
//    	   role11.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadImport:*");
//    	   role12.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("leadFellow:*");
//    	   role13.setPermissions(permissions);
//    	   //set permissions for appointment and call
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("callAdd:*");
//    	   role14.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("callEdit:*");
//    	   role15.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("callView:*");
//    	   role16.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("appointmentAdd:*");
//    	   role17.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("appointmentEdit:*");
//    	   role18.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("appointmentView:*");
//    	   role19.setPermissions(permissions);
//    	   //set permissions for account
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("accountAdd:*");
//    	   role20.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("accountEdit:*");
//    	   role21.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("accountDelete:*");
//    	   role22.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("accountView:*");
//    	   role23.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("accountConvert:*");
//    	   role24.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("accountFellow:*");
//    	   role25.setPermissions(permissions);
//    	   //set permissions for contact
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("contactAdd:*");
//    	   role26.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("contactEdit:*");
//    	   role27.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("contactDelete:*");
//    	   role28.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("contactView:*");
//    	   role29.setPermissions(permissions);
//    	   permissions = new HashSet<String>(); 
//    	   permissions.add("contactFellow:*");
//    	   role30.setPermissions(permissions);
//    	   
//    	   roleShiroService.addRole(role1);
//    	   roleShiroService.addRole(role2);
//    	   roleShiroService.addRole(role3);
//    	   roleShiroService.addRole(role4);
//    	   roleShiroService.addRole(role5);
//    	   roleShiroService.addRole(role6);
//    	   
//    	   roleShiroService.addRole(role7);
//    	   roleShiroService.addRole(role8);
//    	   roleShiroService.addRole(role9);
//    	   roleShiroService.addRole(role10);
//    	   roleShiroService.addRole(role11);
//    	   roleShiroService.addRole(role12);
//    	   roleShiroService.addRole(role13);
//    	   roleShiroService.addRole(role14);
//    	   roleShiroService.addRole(role15);
//    	   roleShiroService.addRole(role16);
//    	   roleShiroService.addRole(role17);
//    	   roleShiroService.addRole(role18);
//    	   roleShiroService.addRole(role19);
//    	   roleShiroService.addRole(role20);
//    	   roleShiroService.addRole(role21);
//    	   roleShiroService.addRole(role22);
//    	   roleShiroService.addRole(role23);
//    	   roleShiroService.addRole(role24);
//    	   roleShiroService.addRole(role25);
//    	   roleShiroService.addRole(role26);
//    	   roleShiroService.addRole(role27);
//    	   roleShiroService.addRole(role28);
//    	   roleShiroService.addRole(role29);
//    	   roleShiroService.addRole(role30);
////    	   userShiroService.addUser(user1);
////        jdbcTemplate.execute("insert into roles values (1, 'user', 'The default role given to all users.')");
////        jdbcTemplate.execute("insert into roles values (2, 'admin', 'The administrator role only given to site admins')");
////    	  jdbcTemplate.execute("insert into roles values (3, 'employee', 'The employee role only given to site admins')");	
////        jdbcTemplate.execute("insert into roles_permissions values (2, 'user:*')");
////    	  jdbcTemplate.execute("insert into roles_permissions values (3, 'employee:*')");
////        jdbcTemplate.execute("insert into users(id,username,email,password) values (1, 'admin', 'sample@shiro.apache.org', '" + new Sha256Hash("admin").toHex() + "')");
////        jdbcTemplate.execute("insert into users(id,username,email,password) values (2, 'employee', 'employee@shiro.apache.org', '" + new Sha256Hash("employee").toHex() + "')");
////    	  jdbcTemplate.execute("insert into users_roles values (2, 3)");
////        jdbcTemplate.execute("insert into users_roles values (1, 2)");
//    //  }
//  }
//}
